package zx.x.modules.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import zx.x.common.utils.R;
import zx.x.modules.app.entity.JqjsEntity;
import zx.x.modules.app.entity.YwglEntity;
import zx.x.modules.app.service.YwglService;

import java.util.Arrays;
import java.util.List;



/**
 * 游玩攻略
 *
 * @author x
 * @email x
 * @date 2023-09-12 17:52:21
 */
@RestController
@RequestMapping("/sys/ywgl")
public class SysYwglController {
    @Autowired
    private YwglService ywglService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(YwglEntity yw){
        QueryWrapper<YwglEntity> queryWrapper = new QueryWrapper<YwglEntity>();
        queryWrapper.eq("delete_flag","0").select(YwglEntity.class, info -> !info.getColumn().equals("text"));
        Page page = PageHelper.startPage(yw.getPage(),yw.getLimit());
        List<YwglEntity> list = ywglService.list(queryWrapper);
        return R.ok().put("page", list).put("pages",page.getPages()).put("total",page.getTotal());
    }


    /**
     * 信息
     */
    @RequestMapping("/info")
    public R info(Integer id){
		YwglEntity ywgl = ywglService.getById(id);
        return R.ok().put("ywgl", ywgl);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody YwglEntity ywgl){
		ywglService.save(ywgl);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody YwglEntity ywgl){
		ywglService.updateById(ywgl);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        ywglService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
